<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="UTF-8">
    <title>全能IPTV播放器</title>
    <!-- 核心 JS 库 (通过 manifest.json 授权) -->
    <script src="libs/hls.js@latest"></script>
    <script src="libs/flv.js@latest"></script>
    
    <!-- 美化库 (通过 manifest.json 授权) -->
    <link rel="stylesheet" href="fontawesome/css/all.min.css">
    <script src="libs/popper.min.js"></script>
    <script src="libs/tippy-bundle.umd.min.js"></script>
    
    <!-- 自己的样式和脚本 -->
    <link rel="stylesheet" href="popup.css">
</head>
<body data-theme="dark">

    <div class="header">
        <div class="header-top">
            <div class="title-group">
                <h1><i class="fa-solid fa-tv"></i> IPTV Player</h1>
                <button id="theme-toggle-btn" data-tippy-content="切换主题"><i class="fa-solid fa-sun"></i></button>
            </div>
            <div id="status-container">
                <span id="modeIndicator" class="status-item"></span>
                <span id="playbackIndicator" class="status-item"></span>
                <span id="checkIndicator" class="status-item"></span>
            </div>
        </div>
        <div class="header-controls">
            <div class="control-group source-group">
                <div class="select-wrapper">
                    <select id="sourceSelector" data-tippy-content="选择一个预设或自定义的源"></select>
                </div>
                <input type="text" id="sourceUrlInput" placeholder="选择或输入源 URL">
            </div>
            <div class="control-group actions-group">
                <button id="loadListBtn" class="btn" data-tippy-content="从URL加载频道列表"><i class="fa-solid fa-cloud-arrow-down"></i><span>加载</span></button>
                <button id="playDirectBtn" class="btn" data-tippy-content="直接播放输入的URL"><i class="fa-solid fa-play"></i><span>播放</span></button>
                <label for="localFileInput" id="loadLocalLabel" class="btn" data-tippy-content="加载本地 M3U 文件"><i class="fa-solid fa-folder-open"></i><span>本地</span></label>
                <input type="file" id="localFileInput" accept=".m3u,.m3u8">
            </div>
            <div class="control-group management-group">
                <button id="saveSourceBtn" class="btn" data-tippy-content="将当前URL保存为自定义源"><i class="fa-solid fa-floppy-disk"></i><span>保存</span></button>
                <button id="deleteSourceBtn" class="btn" disabled data-tippy-content="删除选中的自定义源"><i class="fa-solid fa-trash-can"></i><span>删除</span></button>
            </div>
            <div class="control-group proxy-group"><input type="text" id="proxyUrlInput" placeholder="代理地址 (可选)" data-tippy-content="为所有网络请求设置代理"></div>
        </div>
    </div>
    <div class="container">
        <div id="playlist">
            <div id="playlist-controls">
                <div id="search-container">
                    <input type="text" id="searchInput" placeholder="搜索频道...">
                    <button id="checkAvailabilityBtn" class="btn" data-tippy-content="检测频道可用性"><i class="fa-solid fa-check-double"></i><span class="btn-text">检测</span></button>
                    <button id="exportBtn" class="btn" data-tippy-content="导出频道列表"><i class="fa-solid fa-file-export"></i><span class="btn-text">导出</span></button>
                </div>
                <div id="filter-container">
                    <button id="filterAllBtn" class="filter-btn btn active">全部</button>
                    <button id="filterAvailableBtn" class="filter-btn btn">可用</button>
                    <button id="filterUnavailableBtn" class="filter-btn btn">无效</button>
                </div>
            </div>
            <div id="channel-list">
                <div class="loader"></div>
                <div class="status-message">请选择源, 或加载本地文件</div>
            </div>
        </div>
        <div id="video-container"><video id="videoPlayer" controls autoplay></video></div>
    </div>
    
    <button id="playlist-toggle" data-tippy-content="切换播放列表"><i class="fa-solid fa-list-ul"></i></button>

    <script src="popup.js"></script>
</body>
</html>